Passed
Branch master (328f34)
by Chubarov
04:39
created

Vue.use.image.uploadHandler   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
nc 2
nop 1
1
import Vue from 'vue/dist/vue.js';
2
import axios from 'axios'
3
import App from './components/App.vue';
4
import ElementUI from 'element-ui'
5
import 'element-ui/lib/theme-default/index.css'
6
import lang from 'element-ui/lib/locale/lang/en'
7
import locale from 'element-ui/lib/locale'
8
import VueHtml5Editor from 'vue-html5-editor'
9
10
Vue.use(VueHtml5Editor, {
11
    name: "vue-html5-editor",
12
    // if set true,will append module name to toolbar after icon
13
    showModuleName: true,
14
    // config image module
15
    image: {
16
        //   max file size
17
        sizeLimit: 512 * 1024,
18
        // upload config,default null and convert image to base64
19
        upload: {
20
            url: null,
21
            headers: {},
22
            params: {},
23
            fieldName: {}
24
        },
25
        // compression config,default resize image by localResizeIMG (https://github.com/think2011/localResizeIMG)
26
        // set null to disable compression
27
        compress: {
28
            width: 1600,
29
            height: 1600,
30
            quality: 80
31
        },
32
        // handle response data,return image url
33
        uploadHandler(responseText){
34
            //default accept json data like  {ok:false,msg:"unexpected"} or {ok:true,data:"image url"}
35
            var json = JSON.parse(responseText)
36
            if (!json.ok) {
37
                alert(json.msg)
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
38
            } else {
39
                return json.data
40
            }
41
        }
42
    },
43
    //default en-us, en-us and zh-cn are built-in
44
    language: "en-us",
45
    i18n: {
46
        //specify your language here
47
        // "zh-cn": {
48
        //     "align": "对齐方式",
49
        //     "image": "图片",
50
        //     "list": "列表",
51
        //     "link": "链接",
52
        //     "unlink": "去除链接",
53
        //     "table": "表格",
54
        //     "font": "文字",
55
        //     "full screen": "全屏",
56
        //     "text": "排版",
57
        //     "eraser": "格式清除",
58
        //     "info": "关于",
59
        //     "color": "颜色",
60
        //     "please enter a url": "请输入地址",
61
        //     "create link": "创建链接",
62
        //     "bold": "加粗",
63
        //     "italic": "倾斜",
64
        //     "underline": "下划线",
65
        //     "strike through": "删除线",
66
        //     "subscript": "上标",
67
        //     "superscript": "下标",
68
        //     "heading": "标题",
69
        //     "font name": "字体",
70
        //     "font size": "文字大小",
71
        //     "left justify": "左对齐",
72
        //     "center justify": "居中",
73
        //     "right justify": "右对齐",
74
        //     "ordered list": "有序列表",
75
        //     "unordered list": "无序列表",
76
        //     "fore color": "前景色",
77
        //     "background color": "背景色",
78
        //     "row count": "行数",
79
        //     "column count": "列数",
80
        //     "save": "确定",
81
        //     "upload": "上传",
82
        //     "progress": "进度",
83
        //     "unknown": "未知",
84
        //     "please wait": "请稍等",
85
        //     "error": "错误",
86
        //     "abort": "中断",
87
        //     "reset": "重置"
88
        // }
89
    },
90
    // the modules you don't want
91
    hiddenModules: [
92
        "full-screen",
93
        "info",
94
        "undo",
95
    ],
96
    // keep only the modules you want and customize the order.
97
    // can be used with hiddenModules together
98
    visibleModules: [
99
        "text",
100
        "color",
101
        "font",
102
        "align",
103
        "list",
104
        "link",
105
        "unlink",
106
        "tabulation",
107
        "image",
108
        "hr",
109
        "eraser",
110
    ],
111
    // extended modules
112
    modules: {
113
        //omit,reference to source code of build-in modules
114
    }
115
});
116
locale.use(lang);
117
Vue.use(ElementUI);
118
Vue.prototype.$http = axios.create();
119
120
new Vue({
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new Vue({IdentifierNode(...,false))),false,true)}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
121
    el: '#root',
122
    data() {
123
        return {
124
            showModal: false
125
        }
126
    },
127
    render: h => h(App),
128
});